package main

import (
	"fmt"
	"sync"
	"time"
)

var wg sync.WaitGroup

func main() {
	now := time.Now()
	println("开始任务")
	for i := 0; i < 10; i++ {
		wg.Add(1)
		go subFunc(uint64(i)) // 去掉go，结果就是10秒
	}
	wg.Wait()
	println("Done")
	fmt.Printf("耗时：%v", time.Now().Sub(now).String())
}

func subFunc(num uint64) {
	println(num)
	time.Sleep(time.Second)

	wg.Done()
}
